/**
 *
 */
package com.rexzhaolei.fizzbuzzwhizz;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author rex.zhao
 *
 */
public class Students implements Iterable<Student> {
	private List<Student> queue = new ArrayList<Student>();

	private Students() {

	}

	public void addStudent(Student student) {
		if (student != null) {
			queue.add(student);
		}
	}

	public void removeStudent(Student student){
		if (student != null) {
			queue.remove(student);
		}
	}

	public void setZzGame(Zz zz){
		for(Student student : queue){
			student.setGame(zz);
		}
	}

	public static Students newStudents(int number) {
		Students students = new Students();
		for (int i = 0; i < number; i++) {
			Student student = new Student();
			student.intoQueue(i + 1);
			students.addStudent(student);
		}

		return students;
	}

	@Override
	public Iterator<Student> iterator() {
		return queue.iterator();
	}

}
